package com.yunhe.authority.controller.feign;

import com.github.stuxuhai.jpinyin.PinyinException;
import com.yunhe.authority.domain.company.ContractAccessories;
import com.yunhe.authority.service.company.CompanyService;
import com.yunhe.common.exception.ArgumentErrorException;
import com.yunhe.common.exception.ModelNotFoundException;
import com.yunhe.common.exception.ObjectNotFoundException;
import com.yunhe.common.exception.UniqueConstraintsException;
import com.yunhe.common.model.ResultObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author zhengbo
 * @date 2021/5/12 9:53
 */
@RestController
@RequestMapping("/companyFeign")
public class FeignCompanyController {

    @Autowired
    private CompanyService companyService;

    /**
     * 成功项目录入在园项目
     *
     */
    @RequestMapping(value = "/intentionToCompany", method = RequestMethod.POST)
    public ResponseEntity<ResultObject<String>> intentionToCompany(@RequestParam(value = "intentionId", required = true) Long intentionId,
                                                           @RequestParam(value = "officeIds", required = false) String officeIds,
                                                           @RequestParam(value = "title", required = true) String title,
                                                           @RequestParam(value = "leaseTime", required = true) String leaseTime,
                                                           @RequestParam(value = "leaseDueTime", required = true) String leaseDueTime,
                                                                   @RequestBody List<ContractAccessories> contractAccessoriesList)
            throws ObjectNotFoundException, UniqueConstraintsException, ArgumentErrorException, PinyinException, ModelNotFoundException {
        return new ResponseEntity<>(new ResultObject<>(companyService.intentionToCompany(intentionId, officeIds, title, leaseTime, leaseDueTime,contractAccessoriesList)), HttpStatus.OK);
    }

}
